<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleleaf.org">
<head th:insert="base">
    <meta charset="UTF-8">
    <title></title>
</head>
    <body class="index">
        <!-- 顶部开始 -->
        <div class="container">
            <div class="logo">
                <a id="systemName" style="font-size: 14px;"></a>
            </div>
            <div class="left_open">
                <a><i title="展开左侧栏" class="iconfont">&#xe699;</i></a>
            </div>
            <ul class="layui-nav right" lay-filter="">
                <li class="layui-nav-item">
                    <a href="javascript:;" id="userName"></a>
                    <dl class="layui-nav-child">
                        <!-- 二级菜单 -->
                        <dd>
                            <a onclick="xadmin.open('修改密码','/back/admin/editpassword')">修改密码</a></dd>
                        <dd>
                            <a href="/back/admin/logout">切换帐号</a></dd>
                        <dd>
                            <a href="/back/admin/logout">退出</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
        <!-- 顶部结束 -->
        <!-- 中部开始 -->
        <!-- 左侧菜单开始 -->
        <div class="left-nav">
            <div id="side-nav">
                <ul id="nav">
                </ul>
            </div>
        </div>
        <!-- <div class="x-slide_left"></div> -->
        <!-- 左侧菜单结束 -->
        <!-- 右侧主体开始 -->
        <div class="page-content">
            <div class="layui-tab tab" lay-filter="xbs_tab" lay-allowclose="false">
                <ul class="layui-tab-title">
                    <li class="home">
                        <i class="layui-icon">&#xe68e;</i>我的桌面</li></ul>
                <div class="layui-unselect layui-form-select layui-form-selected" id="tab_right">
                    <dl>
                        <dd data-type="this">关闭当前</dd>
                        <dd data-type="other">关闭其它</dd>
                        <dd data-type="all">关闭全部</dd></dl>
                </div>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <iframe src='/back/welcome' frameborder="0" scrolling="yes" class="x-iframe"></iframe>
                    </div>
                </div>
                <div id="tab_show"></div>
            </div>
        </div>
        <div class="page-content-bg"></div>
        <style id="theme_style"></style>
        <!-- 右侧主体结束 -->
    </body>
<script th:inline="javascript">
    layui.use(['element', 'jquery', 'form'], function () {
        var element = layui.element;
        var form = layui.form;
        var $ = layui.jquery;
        var userInfo = [[${userInfo}]];

        $("#systemName").html(systemName);
        $("#userName").html(userInfo.nickName);
        init_menu(userInfo.roleCode);

        /**
         * 根据角色获取相应菜单
         */
        function init_menu(roleCode) {
            $.ajax({
                url:'/back/admin/getMenus'
                ,type:'post'
                ,data: {
                    roleCode: roleCode
                }
                ,async:false
                ,dataType:'json'
                ,success:function(res){
                    if(res.code == '0'){
                        $("#nav").empty();
                        for(var i = 0;i < res.data.length;i++){
                            var menuGroupHtml = "<li>\n" +
                                "                <a href=\"javascript:;\">\n" +
                                "                    <i class=\"iconfont left-nav-li layui-icon "+res.data[i].showIcon+"\" lay-tips=\""+res.data[i].permissionName+"\"></i>\n" +
                                "                    <cite>"+res.data[i].permissionName+"</cite>\n" +
                                "                    <i class=\"iconfont nav_right\">&#xe697;</i></a>\n" +
                                "                <ul class=\"sub-menu\" id=\"m_"+res.data[i].permissionCode+"\">\n" +
                                "                </ul>\n" +
                                "            </li>";
                            $("#nav").append(menuGroupHtml);
                            for(var j = 0;j < res.data[i].childrenData.length;j++){
                                var menuHtml = "<li>\n" +
                                    "                        <a onclick=\"xadmin.add_tab('"+res.data[i].childrenData[j].permissionName+"','"+res.data[i].childrenData[j].permissionUrl+"',true)\">\n" +
                                    "                            <i class=\"iconfont\">&#xe6a7;</i>\n" +
                                    "                            <cite>"+res.data[i].childrenData[j].permissionName+"</cite></a>\n" +
                                    "                    </li>";
                                $("#m_"+res.data[i].permissionCode).append(menuHtml);
                            }
                        }
                        form.render();
                    }else {
                        layer.msg("加载菜单失败", {
                                icon: msg.error,
                                time: 2000
                            },
                            null
                        );
                    }
                }
                ,error:function(){
                    layer.msg("网络故障", {
                            icon: msg.error,
                            time: 2000
                        },
                        null
                    );
                }
            });
        }
    });
</script>
</html>